package com.neutech.maplestory.entity;

import com.neutech.maplestory.client.MapleStoryClient;
import com.neutech.maplestory.util.ImageUtil;

import java.awt.*;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author Neuedu-远哥
 * @version 1.0
 * @date 2021/12/3 10:09
 */
public class ItemPackage extends AbstractMapleStoryObject {

    public List<Item> items = new CopyOnWriteArrayList<>();

    public ItemPackage(){}

    public ItemPackage(MapleStoryClient msc,int x,int y){
        this();
        this.msc = msc;
        this.x = x;
        this.y = y;
        this.img = ImageUtil.getImageByKey("item_package");
        this.live = false;
    }

    @Override
    public void draw(Graphics g) {
        if(live){
            // 画道具包
            g.drawImage(img,x,y,null);
            // 本类的道具包容器
            for(int i= 0;i<items.size();i++){
                Item item = items.get(i);
                // 第一行
                if(i >= 0 && i< 4){
                    g.drawImage(item.img,x + i * 36 + 13,y + 53,null);
                    g.drawString("" + item.qty,i * 36 + x + 11, y + 83);
                }
                if(i >= 4 && i< 8){
                    g.drawImage(item.img,x + (i-4) * 36 + 13,y + 53 + 35,null);
                    g.drawString("" + item.qty,(i-4) * 36 + x + 11, y + 83 + 35);
                }

            }
        }
    }
}
